<!DOCTYPE html>
<html lang="zh-CN">
{% load static %}
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- SEO Meta标签 -->
    <title>{% if article.meta_title %}{{ article.meta_title }}{% else %}{{ article.title }} - IP地址定位分析系统{% endif %}</title>
    <meta name="description" content="{% if article.meta_description %}{{ article.meta_description }}{% else %}{{ article.summary|default:article.title }}{% endif %}">
    <meta name="keywords" content="{% if article.meta_keywords %}{{ article.meta_keywords }}{% else %}{% for tag in article.tags.all %}{{ tag.name }}, {% endfor %}IP分析, IP定位{% endif %}">
    <meta name="author" content="{{ article.created_by.username|default:'管理员' }}">
    <meta name="robots" content="index, follow">
    <meta name="revisit-after" content="7 days">
    <link rel="canonical" href="{{ request.build_absolute_uri }}">
    
    <!-- Open Graph标签 -->
    <meta property="og:title" content="{% if article.meta_title %}{{ article.meta_title }}{% else %}{{ article.title }}{% endif %}">
    <meta property="og:description" content="{% if article.meta_description %}{{ article.meta_description }}{% else %}{{ article.summary|default:article.title }}{% endif %}">
    <meta property="og:url" content="{{ request.build_absolute_uri }}">
    <meta property="og:type" content="article">
    <meta property="og:site_name" content="IP地址定位分析系统">
    
    <!-- Twitter卡片 -->
    <meta name="twitter:card" content="summary">
    <meta name="twitter:title" content="{% if article.meta_title %}{{ article.meta_title }}{% else %}{{ article.title }}{% endif %}">
    <meta name="twitter:description" content="{% if article.meta_description %}{{ article.meta_description }}{% else %}{{ article.summary|default:article.title }}{% endif %}">
    
    <!-- 代码高亮样式 -->
    <link rel="stylesheet" href="{% static 'highlightjs/monokai-sublime.min.css' %}">
    <script src="{% static 'highlightjs/highlight.min.js' %}"></script>
    <script>hljs.highlightAll();</script>
    
    <style>
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
            background-color: #f5f5f5;
            margin: 0;
            padding: 0;
            color: #333;
            line-height: 1.6;
        }
        .container {
            max-width: 800px;
            width: 90%;
            margin: 40px auto;
            background-color: white;
            padding: 40px;
            border-radius: 16px;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
        }
        h1 {
            color: #2c3e50;
            margin-bottom: 20px;
            font-size: 28px;
            font-weight: 700;
            line-height: 1.3;
        }
        .article-meta {
            color: #7f8c8d;
            margin-bottom: 30px;
            padding-bottom: 20px;
            border-bottom: 2px solid #f0f0f0;
            display: flex;
            flex-wrap: wrap;
            gap: 20px;
            align-items: center;
        }
        .meta-item {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 14px;
        }
        .article-content {
            color: #4a5568;
            font-size: 16px;
            margin-bottom: 40px;
        }
        .article-content p {
            margin-bottom: 20px;
            line-height: 1.8;
        }
        .article-content h2 {
            color: #2c3e50;
            font-size: 24px;
            margin-top: 40px;
            margin-bottom: 20px;
            padding-bottom: 10px;
            border-bottom: 2px solid #e0e0e0;
        }
        .article-content h3 {
            color: #34495e;
            font-size: 20px;
            margin-top: 30px;
            margin-bottom: 15px;
        }
        .article-content ul,
        .article-content ol {
            margin-bottom: 20px;
            padding-left: 25px;
        }
        .article-content li {
            margin-bottom: 8px;
        }
        .article-content img {
            max-width: 100%;
            height: auto;
            border-radius: 8px;
            margin: 20px 0;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        }
        
        /* 代码高亮样式 */
        .article-content pre {
            background-color: #272822;
            border-radius: 8px;
            padding: 15px;
            margin: 20px 0;
            overflow-x: auto;
            position: relative;
        }
        
        .article-content code {
            font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
            font-size: 14px;
            line-height: 1.5;
        }
        
        .article-content pre code {
            background-color: transparent;
            color: #f8f8f2;
            padding: 0;
        }
        
        .article-content code {
            background-color: #f1f1f1;
            padding: 2px 5px;
            border-radius: 3px;
            color: #e74c3c;
        }
        .article-tags {
            margin-bottom: 30px;
            padding-top: 20px;
            border-top: 2px solid #f0f0f0;
        }
        .tag {
            display: inline-block;
            background-color: #ecf0f1;
            color: #3498db;
            padding: 6px 12px;
            border-radius: 20px;
            font-size: 14px;
            margin-right: 10px;
            margin-bottom: 10px;
            text-decoration: none;
            transition: all 0.3s ease;
        }
        .tag:hover {
            background-color: #3498db;
            color: white;
            transform: translateY(-1px);
        }
        .related-articles {
            margin-top: 40px;
            padding-top: 30px;
            border-top: 2px solid #f0f0f0;
        }
        .related-articles h3 {
            color: #2c3e50;
            margin-bottom: 20px;
            font-size: 20px;
        }
        .related-article-list {
            list-style: none;
            padding: 0;
            margin: 0;
        }
        .related-article-item {
            margin-bottom: 15px;
            padding-bottom: 15px;
            border-bottom: 1px solid #f0f0f0;
        }
        .related-article-item:last-child {
            margin-bottom: 0;
            padding-bottom: 0;
            border-bottom: none;
        }
        .related-article-link {
            color: #2c3e50;
            text-decoration: none;
            font-weight: 500;
            transition: color 0.3s ease;
            display: block;
            margin-bottom: 5px;
        }
        .related-article-link:hover {
            color: #3498db;
        }
        .related-article-meta {
            color: #7f8c8d;
            font-size: 12px;
        }
        .back-link {
            display: inline-block;
            background-color: #3498db;
            color: white;
            padding: 12px 20px;
            border-radius: 8px;
            text-decoration: none;
            font-weight: 500;
            transition: all 0.3s ease;
            margin-top: 20px;
        }
        .back-link:hover {
            background-color: #2980b9;
            transform: translateY(-1px);
        }
        .sticky-badge {
            display: inline-block;
            background-color: #f1c40f;
            color: white;
            padding: 4px 12px;
            border-radius: 12px;
            font-size: 12px;
            font-weight: 600;
            margin-right: 10px;
        }
        .social-share {
            margin-top: 30px;
            padding-top: 20px;
            border-top: 2px solid #f0f0f0;
        }
        .social-share h4 {
            color: #2c3e50;
            margin-bottom: 15px;
            font-size: 16px;
        }
        .share-buttons {
            display: flex;
            gap: 10px;
            flex-wrap: wrap;
        }
        .share-button {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            padding: 8px 15px;
            border-radius: 8px;
            text-decoration: none;
            font-size: 14px;
            font-weight: 500;
            transition: all 0.3s ease;
            color: white;
        }
        .share-button:hover {
            transform: translateY(-1px);
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
        }
        .share-wechat {
            background-color: #07C160;
        }
        .share-weibo {
            background-color: #E6162D;
        }
        .share-qq {
            background-color: #12B7F5;
        }
    </style>
</head>
<body>
    <div class="container">
        <!-- 文章标题 -->
        <h1>
            {% if article.is_sticky %}<span class="sticky-badge">置顶</span>{% endif %}
            {{ article.title }}
        </h1>
        
        <!-- 文章元信息 -->
        <div class="article-meta">
            <div class="meta-item">
                <span>📅</span>
                <span>{{ article.publish_date|date:"Y年m月d日 H:i" }}</span>
            </div>
            <div class="meta-item">
                <span>👤</span>
                <span>{{ article.created_by.username|default:'管理员' }}</span>
            </div>
            <div class="meta-item">
                <span>👁️</span>
                <span>{{ article.view_count }}次阅读</span>
            </div>
            <div class="meta-item">
                <span>💬</span>
                <span>评论 (0)</span>
            </div>
        </div>
        
        <!-- 文章内容 -->
        <div class="article-content">
            {{ article.content|safe }}
        </div>
        
        <!-- 文章标签 -->
        {% if article.tags.all %}
        <div class="article-tags">
            <strong>标签：</strong>
            {% for tag in article.tags.all %}
            <a href="{% url 'article_list' %}?tag={{ tag.name }}" class="tag">{{ tag.name }}</a>
            {% endfor %}
        </div>
        {% endif %}
        
        <!-- 分享按钮 -->
        <div class="social-share">
            <h4>分享文章</h4>
            <div class="share-buttons">
                <a href="javascript:void(0);" class="share-button share-wechat">
                    <span>💬</span>
                    <span>微信</span>
                </a>
                <a href="https://service.weibo.com/share/share.php?url={{ request.build_absolute_uri }}&title={{ article.title }}" target="_blank" class="share-button share-weibo">
                    <span>📢</span>
                    <span>微博</span>
                </a>
                <a href="http://connect.qq.com/widget/shareqq/index.html?url={{ request.build_absolute_uri }}&title={{ article.title }}&desc={{ article.summary|default:article.title }}" target="_blank" class="share-button share-qq">
                    <span>💭</span>
                    <span>QQ</span>
                </a>
            </div>
        </div>
        
        <!-- 相关文章 -->
        {% if related_articles %}
        <div class="related-articles">
            <h3>相关文章</h3>
            <ul class="related-article-list">
                {% for related_article in related_articles %}
                <li class="related-article-item">
                    <a href="{% url 'article_detail' related_article.id %}" class="related-article-link">{{ related_article.title }}</a>
                    <div class="related-article-meta">
                        {{ related_article.publish_date|date:"Y-m-d" }} · {{ related_article.view_count }}次阅读
                    </div>
                </li>
                {% endfor %}
            </ul>
        </div>
        {% endif %}
        
        <!-- 返回按钮 -->
        <a href="{% url 'article_list' %}" class="back-link">
            ← 返回文章列表
        </a>
    </div>
    
    <!-- 底部 -->
    <footer style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; text-align: center; padding: 30px 15px; margin-top: 60px; font-size: 14px; width: 100%;">
        <div style="max-width: 800px; margin: 0 auto;">
            <div style="display: flex; justify-content: center; gap: 30px; flex-wrap: wrap;">
                <div style="text-align: center; margin-bottom: 20px;">
                    <div style="font-size: 24px; margin-bottom: 10px;">📁</div>
                    <div style="font-weight: 600; margin-bottom: 8px; font-size: 15px;">最新源代码</div>
                    <a href="https://gitee.com/yyping2019/ip-region-query.git" target="_blank" style="color: rgba(255,255,255,0.9); text-decoration: none; font-weight: 500; transition: all 0.3s ease;" 
                       onmouseover="this.style.color='white'; this.style.transform='translateY(-1px)';" 
                       onmouseout="this.style.color='rgba(255,255,255,0.9)'; this.style.transform='translateY(0);'">
                        Gitee仓库 →
                    </a>
                </div>
                <div style="text-align: center;">
                    <div style="font-size: 24px; margin-bottom: 10px;">👨‍💻</div>
                    <div style="font-weight: 600; margin-bottom: 8px; font-size: 15px;">开发者联系</div>
                    <a href="mailto:admin@ip997.com" style="color: rgba(255,255,255,0.9); text-decoration: none; font-weight: 500; transition: all 0.3s ease;"
                       onmouseover="this.style.color='white'; this.style.transform='translateY(-1px)';" 
                       onmouseout="this.style.color='rgba(255,255,255,0.9); this.style.transform='translateY(0);'">
                        admin@ip997.com
                    </a>
                </div>
            </div>
            <div style="margin-top: 20px; padding-top: 15px; border-top: 1px solid rgba(255,255,255,0.2); color: rgba(255,255,255,0.8); font-size: 12px;">
                © 2025 IP地址定位分析系统 | 基于Django开发
            </div>
        </div>
    </footer>
    
    <script>
        // 平滑滚动
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
                document.querySelector(this.getAttribute('href')).scrollIntoView({ 
                    behavior: 'smooth' 
                });
            });
        });
        
        // 阅读进度条
        window.addEventListener('scroll', function() {
            const winScroll = document.body.scrollTop || document.documentElement.scrollTop;
            const height = document.documentElement.scrollHeight - document.documentElement.clientHeight;
            const scrolled = (winScroll / height) * 100;
            // 可以在这里添加进度条显示
        });
    </script>
</body>
</html>